using SheLife.Application.Interfaces;
using SheLife.Domain.Entities;
using SheLife.Infrastructure.Repositories;

namespace SheLife.Application.Services
{
    /// <summary>
    /// 服装服务实现
    /// </summary>
    public class ClothingService : IClothingService
    {
        private readonly IUnitOfWork _unitOfWork;

        public ClothingService(IUnitOfWork unitOfWork)
        {
            _unitOfWork = unitOfWork;
        }

        public async Task<Clothing?> GetClothingByIdAsync(Guid id)
        {
            return await _unitOfWork.ClothingRepository.GetByIdAsync(id);
        }

        public async Task<IEnumerable<Clothing>> GetClothingsByUserIdAsync(Guid userId)
        {
            return await _unitOfWork.ClothingRepository.GetByUserIdAsync(userId);
        }

        public async Task<IEnumerable<Clothing>> GetClothingsByUserIdAndCategoryAsync(Guid userId, string category)
        {
            return await _unitOfWork.ClothingRepository.GetByUserIdAndCategoryAsync(userId, category);
        }

        public async Task<IEnumerable<Clothing>> GetClothingsByUserIdAndColorAsync(Guid userId, string color)
        {
            return await _unitOfWork.ClothingRepository.GetByUserIdAndColorAsync(userId, color);
        }

        public async Task<IEnumerable<Clothing>> GetClothingsByUserIdAndSeasonAsync(Guid userId, string season)
        {
            return await _unitOfWork.ClothingRepository.GetByUserIdAndSeasonAsync(userId, season);
        }

        public async Task<Clothing> CreateClothingAsync(Guid userId, string name, string category, string color, string season, string? imageUrl = null, string? notes = null)
        {
            var clothing = new Clothing
            {
                Id = Guid.NewGuid(),
                UserId = userId,
                Name = name,
                Category = category,
                Color = color,
                Season = season,
                ImageUrl = imageUrl,
                Notes = notes,
                CreatedAt = DateTime.UtcNow,
                UpdatedAt = DateTime.UtcNow
            };

            await _unitOfWork.ClothingRepository.AddAsync(clothing);
            await _unitOfWork.SaveChangesAsync();

            return clothing;
        }

        public async Task<Clothing?> UpdateClothingAsync(Guid id, string? name, string? category, string? color, string? season, string? imageUrl = null, string? notes = null)
        {
            var clothing = await _unitOfWork.ClothingRepository.GetByIdAsync(id);
            if (clothing == null)
                return null;

            if (name != null) clothing.Name = name;
            if (category != null) clothing.Category = category;
            if (color != null) clothing.Color = color;
            if (season != null) clothing.Season = season;
            if (imageUrl != null) clothing.ImageUrl = imageUrl;
            if (notes != null) clothing.Notes = notes;

            clothing.UpdatedAt = DateTime.UtcNow;

            await _unitOfWork.ClothingRepository.UpdateAsync(clothing);
            await _unitOfWork.SaveChangesAsync();

            return clothing;
        }

        public async Task<bool> DeleteClothingAsync(Guid id)
        {
            var clothing = await _clothingRepository.GetByIdAsync(id);
            if (clothing == null)
                return false;

            await _unitOfWork.ClothingRepository.DeleteAsync(clothing);
            await _unitOfWork.SaveChangesAsync();

            return true;
        }
    }

    /// <summary>
    /// 搭配服务实现
    /// </summary>
    public class OutfitService : IOutfitService
    {
        private readonly IUnitOfWork _unitOfWork;

        public OutfitService(IUnitOfWork unitOfWork)
        {
            _unitOfWork = unitOfWork;
        }

        public async Task<Outfit?> GetOutfitByIdAsync(Guid id)
        {
            return await _unitOfWork.OutfitRepository.GetByIdAsync(id);
        }

        public async Task<IEnumerable<Outfit>> GetOutfitsByUserIdAsync(Guid userId)
        {
            return await _unitOfWork.OutfitRepository.GetByUserIdAsync(userId);
        }

        public async Task<IEnumerable<Outfit>> GetOutfitsByUserIdAndOccasionAsync(Guid userId, string occasion)
        {
            return await _unitOfWork.OutfitRepository.GetByUserIdAndOccasionAsync(userId, occasion);
        }

        public async Task<IEnumerable<Outfit>> GetOutfitsByUserIdAndSeasonAsync(Guid userId, string season)
        {
            return await _unitOfWork.OutfitRepository.GetByUserIdAndSeasonAsync(userId, season);
        }

        public async Task<Outfit> CreateOutfitAsync(Guid userId, string name, string description, string occasion, string season, string? imageUrl = null)
        {
            var outfit = new Outfit
            {
                Id = Guid.NewGuid(),
                UserId = userId,
                Name = name,
                Description = description,
                Occasion = occasion,
                Season = season,
                ImageUrl = imageUrl,
                CreatedAt = DateTime.UtcNow,
                UpdatedAt = DateTime.UtcNow
            };

            await _unitOfWork.OutfitRepository.AddAsync(outfit);
            await _unitOfWork.SaveChangesAsync();

            return outfit;
        }

        public async Task<Outfit?> UpdateOutfitAsync(Guid id, string? name, string? description, string? occasion, string? season, string? imageUrl = null)
        {
            var outfit = await _unitOfWork.OutfitRepository.GetByIdAsync(id);
            if (outfit == null)
                return null;

            if (name != null) outfit.Name = name;
            if (description != null) outfit.Description = description;
            if (occasion != null) outfit.Occasion = occasion;
            if (season != null) outfit.Season = season;
            if (imageUrl != null) outfit.ImageUrl = imageUrl;

            outfit.UpdatedAt = DateTime.UtcNow;

            await _unitOfWork.OutfitRepository.UpdateAsync(outfit);
            await _unitOfWork.SaveChangesAsync();

            return outfit;
        }

        public async Task<bool> DeleteOutfitAsync(Guid id)
        {
            var outfit = await _unitOfWork.OutfitRepository.GetByIdAsync(id);
            if (outfit == null)
                return false;

            await _unitOfWork.OutfitRepository.DeleteAsync(outfit);
            await _unitOfWork.SaveChangesAsync();

            return true;
        }
    }

    /// <summary>
    /// 搭配服装服务实现
    /// </summary>
    public class OutfitClothingService : IOutfitClothingService
    {
        private readonly IUnitOfWork _unitOfWork;

        public OutfitClothingService(IUnitOfWork unitOfWork)
        {
            _unitOfWork = unitOfWork;
        }

        public async Task<OutfitClothing?> GetOutfitClothingByIdAsync(Guid id)
        {
            return await _unitOfWork.OutfitClothingRepository.GetByIdAsync(id);
        }

        public async Task<IEnumerable<OutfitClothing>> GetOutfitClothingsByOutfitIdAsync(Guid outfitId)
        {
            return await _unitOfWork.OutfitClothingRepository.GetByOutfitIdAsync(outfitId);
        }

        public async Task<IEnumerable<OutfitClothing>> GetOutfitClothingsByClothingIdAsync(Guid clothingId)
        {
            return await _unitOfWork.OutfitClothingRepository.GetByClothingIdAsync(clothingId);
        }

        public async Task<OutfitClothing> CreateOutfitClothingAsync(Guid outfitId, Guid clothingId)
        {
            var outfitClothing = new OutfitClothing
            {
                Id = Guid.NewGuid(),
                OutfitId = outfitId,
                ClothingId = clothingId,
                CreatedAt = DateTime.UtcNow
            };

            await _unitOfWork.OutfitClothingRepository.AddAsync(outfitClothing);
            await _unitOfWork.SaveChangesAsync();

            return outfitClothing;
        }

        public async Task<bool> DeleteOutfitClothingAsync(Guid id)
        {
            var outfitClothing = await _unitOfWork.OutfitClothingRepository.GetByIdAsync(id);
            if (outfitClothing == null)
                return false;

            await _unitOfWork.OutfitClothingRepository.DeleteAsync(outfitClothing);
            await _unitOfWork.SaveChangesAsync();

            return true;
        }
    }

    /// <summary>
    /// 搭配记录服务实现
    /// </summary>
    public class OutfitRecordService : IOutfitRecordService
    {
        private readonly IOutfitRecordRepository _outfitRecordRepository;
        private readonly IUnitOfWork _unitOfWork;

        public OutfitRecordService(IOutfitRecordRepository outfitRecordRepository, IUnitOfWork unitOfWork)
        {
            _outfitRecordRepository = outfitRecordRepository;
            _unitOfWork = unitOfWork;
        }

        public async Task<OutfitRecord?> GetOutfitRecordByIdAsync(Guid id)
        {
            return await _outfitRecordRepository.GetByIdAsync(id);
        }

        public async Task<IEnumerable<OutfitRecord>> GetOutfitRecordsByUserIdAsync(Guid userId)
        {
            return await _outfitRecordRepository.GetByUserIdAsync(userId);
        }

        public async Task<IEnumerable<OutfitRecord>> GetOutfitRecordsByUserIdAndDateRangeAsync(Guid userId, DateTime startDate, DateTime endDate)
        {
            return await _outfitRecordRepository.GetByUserIdAndDateRangeAsync(userId, startDate, endDate);
        }

        public async Task<IEnumerable<OutfitRecord>> GetOutfitRecordsByUserIdAndOccasionAsync(Guid userId, string occasion)
        {
            return await _outfitRecordRepository.GetByUserIdAndOccasionAsync(userId, occasion);
        }

        public async Task<OutfitRecord> CreateOutfitRecordAsync(Guid userId, Guid outfitId, DateTime date, string? notes = null)
        {
            var outfitRecord = new OutfitRecord
            {
                Id = Guid.NewGuid(),
                UserId = userId,
                OutfitId = outfitId,
                Date = date,
                Notes = notes,
                CreatedAt = DateTime.UtcNow,
                UpdatedAt = DateTime.UtcNow
            };

            await _outfitRecordRepository.AddAsync(outfitRecord);
            await _unitOfWork.SaveChangesAsync();

            return outfitRecord;
        }

        public async Task<OutfitRecord?> UpdateOutfitRecordAsync(Guid id, DateTime? date, string? notes)
        {
            var outfitRecord = await _outfitRecordRepository.GetByIdAsync(id);
            if (outfitRecord == null)
                return null;

            if (date.HasValue) outfitRecord.Date = date.Value;
            if (notes != null) outfitRecord.Notes = notes;

            outfitRecord.UpdatedAt = DateTime.UtcNow;

            await _outfitRecordRepository.UpdateAsync(outfitRecord);
            await _unitOfWork.SaveChangesAsync();

            return outfitRecord;
        }

        public async Task<bool> DeleteOutfitRecordAsync(Guid id)
        {
            var outfitRecord = await _outfitRecordRepository.GetByIdAsync(id);
            if (outfitRecord == null)
                return false;

            await _outfitRecordRepository.DeleteAsync(outfitRecord);
            await _unitOfWork.SaveChangesAsync();

            return true;
        }

        public async Task<Dictionary<string, object>> GetOutfitStatisticsAsync(Guid userId, int days = 30)
        {
            var endDate = DateTime.UtcNow;
            var startDate = endDate.AddDays(-days);

            var records = await _outfitRecordRepository.GetByUserIdAndDateRangeAsync(userId, startDate, endDate);

            var statistics = new Dictionary<string, object>
            {
                ["TotalRecords"] = records.Count(),
                ["MostUsedOccasion"] = records.GroupBy(r => r.Outfit.Occasion)
                                             .OrderByDescending(g => g.Count())
                                             .Select(g => g.Key)
                                             .FirstOrDefault() ?? "无数据",
                ["MostUsedSeason"] = records.GroupBy(r => r.Outfit.Season)
                                           .OrderByDescending(g => g.Count())
                                           .Select(g => g.Key)
                                           .FirstOrDefault() ?? "无数据",
                ["RecordsByDate"] = records.GroupBy(r => r.Date.Date)
                                          .ToDictionary(g => g.Key.ToString("yyyy-MM-dd"), g => g.Count())
            };

            return statistics;
        }
    }

    /// <summary>
    /// 搭配模板服务实现
    /// </summary>
    public class OutfitTemplateService : IOutfitTemplateService
    {
        private readonly IOutfitTemplateRepository _outfitTemplateRepository;
        private readonly IUnitOfWork _unitOfWork;

        public OutfitTemplateService(IOutfitTemplateRepository outfitTemplateRepository, IUnitOfWork unitOfWork)
        {
            _outfitTemplateRepository = outfitTemplateRepository;
            _unitOfWork = unitOfWork;
        }

        public async Task<OutfitTemplate?> GetOutfitTemplateByIdAsync(Guid id)
        {
            return await _outfitTemplateRepository.GetByIdAsync(id);
        }

        public async Task<IEnumerable<OutfitTemplate>> GetAllOutfitTemplatesAsync()
        {
            return await _outfitTemplateRepository.GetAllAsync();
        }

        public async Task<IEnumerable<OutfitTemplate>> GetOutfitTemplatesByCategoryAsync(string category)
        {
            return await _outfitTemplateRepository.GetByCategoryAsync(category);
        }

        public async Task<IEnumerable<OutfitTemplate>> GetOutfitTemplatesByOccasionAsync(string occasion)
        {
            return await _outfitTemplateRepository.GetByOccasionAsync(occasion);
        }

        public async Task<IEnumerable<OutfitTemplate>> GetOutfitTemplatesBySeasonAsync(string season)
        {
            return await _outfitTemplateRepository.GetBySeasonAsync(season);
        }

        public async Task<IEnumerable<OutfitTemplate>> SearchOutfitTemplatesAsync(string keyword)
        {
            return await _outfitTemplateRepository.SearchAsync(keyword);
        }

        public async Task<OutfitTemplate> CreateOutfitTemplateAsync(string name, string description, string category, string occasion, string season, string? imageUrl = null)
        {
            var outfitTemplate = new OutfitTemplate
            {
                Id = Guid.NewGuid(),
                Name = name,
                Description = description,
                Category = category,
                Occasion = occasion,
                Season = season,
                ImageUrl = imageUrl,
                CreatedAt = DateTime.UtcNow,
                UpdatedAt = DateTime.UtcNow
            };

            await _outfitTemplateRepository.AddAsync(outfitTemplate);
            await _unitOfWork.SaveChangesAsync();

            return outfitTemplate;
        }

        public async Task<OutfitTemplate?> UpdateOutfitTemplateAsync(Guid id, string? name, string? description, string? category, string? occasion, string? season, string? imageUrl = null)
        {
            var outfitTemplate = await _outfitTemplateRepository.GetByIdAsync(id);
            if (outfitTemplate == null)
                return null;

            if (name != null) outfitTemplate.Name = name;
            if (description != null) outfitTemplate.Description = description;
            if (category != null) outfitTemplate.Category = category;
            if (occasion != null) outfitTemplate.Occasion = occasion;
            if (season != null) outfitTemplate.Season = season;
            if (imageUrl != null) outfitTemplate.ImageUrl = imageUrl;

            outfitTemplate.UpdatedAt = DateTime.UtcNow;

            await _outfitTemplateRepository.UpdateAsync(outfitTemplate);
            await _unitOfWork.SaveChangesAsync();

            return outfitTemplate;
        }

        public async Task<bool> DeleteOutfitTemplateAsync(Guid id)
        {
            var outfitTemplate = await _outfitTemplateRepository.GetByIdAsync(id);
            if (outfitTemplate == null)
                return false;

            await _outfitTemplateRepository.DeleteAsync(outfitTemplate);
            await _unitOfWork.SaveChangesAsync();

            return true;
        }
    }

    /// <summary>
    /// 搭配模板项服务实现
    /// </summary>
    public class OutfitTemplateItemService : IOutfitTemplateItemService
    {
        private readonly IOutfitTemplateItemRepository _outfitTemplateItemRepository;
        private readonly IUnitOfWork _unitOfWork;

        public OutfitTemplateItemService(IOutfitTemplateItemRepository outfitTemplateItemRepository, IUnitOfWork unitOfWork)
        {
            _outfitTemplateItemRepository = outfitTemplateItemRepository;
            _unitOfWork = unitOfWork;
        }

        public async Task<OutfitTemplateItem?> GetOutfitTemplateItemByIdAsync(Guid id)
        {
            return await _outfitTemplateItemRepository.GetByIdAsync(id);
        }

        public async Task<IEnumerable<OutfitTemplateItem>> GetOutfitTemplateItemsByTemplateIdAsync(Guid templateId)
        {
            return await _outfitTemplateItemRepository.GetByTemplateIdAsync(templateId);
        }

        public async Task<OutfitTemplateItem> CreateOutfitTemplateItemAsync(Guid templateId, string category, string description, string? imageUrl = null)
        {
            var outfitTemplateItem = new OutfitTemplateItem
            {
                Id = Guid.NewGuid(),
                TemplateId = templateId,
                Category = category,
                Description = description,
                ImageUrl = imageUrl,
                CreatedAt = DateTime.UtcNow,
                UpdatedAt = DateTime.UtcNow
            };

            await _outfitTemplateItemRepository.AddAsync(outfitTemplateItem);
            await _unitOfWork.SaveChangesAsync();

            return outfitTemplateItem;
        }

        public async Task<OutfitTemplateItem?> UpdateOutfitTemplateItemAsync(Guid id, string? category, string? description, string? imageUrl = null)
        {
            var outfitTemplateItem = await _outfitTemplateItemRepository.GetByIdAsync(id);
            if (outfitTemplateItem == null)
                return null;

            if (category != null) outfitTemplateItem.Category = category;
            if (description != null) outfitTemplateItem.Description = description;
            if (imageUrl != null) outfitTemplateItem.ImageUrl = imageUrl;

            outfitTemplateItem.UpdatedAt = DateTime.UtcNow;

            await _outfitTemplateItemRepository.UpdateAsync(outfitTemplateItem);
            await _unitOfWork.SaveChangesAsync();

            return outfitTemplateItem;
        }

        public async Task<bool> DeleteOutfitTemplateItemAsync(Guid id)
        {
            var outfitTemplateItem = await _outfitTemplateItemRepository.GetByIdAsync(id);
            if (outfitTemplateItem == null)
                return false;

            await _outfitTemplateItemRepository.DeleteAsync(outfitTemplateItem);
            await _unitOfWork.SaveChangesAsync();

            return true;
        }
    }

    /// <summary>
    /// 用户搭配模板服务实现
    /// </summary>
    public class UserOutfitTemplateService : IUserOutfitTemplateService
    {
        private readonly IUserOutfitTemplateRepository _userOutfitTemplateRepository;
        private readonly IUnitOfWork _unitOfWork;

        public UserOutfitTemplateService(IUserOutfitTemplateRepository userOutfitTemplateRepository, IUnitOfWork unitOfWork)
        {
            _userOutfitTemplateRepository = userOutfitTemplateRepository;
            _unitOfWork = unitOfWork;
        }

        public async Task<UserOutfitTemplate?> GetUserOutfitTemplateByIdAsync(Guid id)
        {
            return await _userOutfitTemplateRepository.GetByIdAsync(id);
        }

        public async Task<IEnumerable<UserOutfitTemplate>> GetUserOutfitTemplatesByUserIdAsync(Guid userId)
        {
            return await _userOutfitTemplateRepository.GetByUserIdAsync(userId);
        }

        public async Task<IEnumerable<UserOutfitTemplate>> GetUserOutfitTemplatesByUserIdAndTemplateIdAsync(Guid userId, Guid templateId)
        {
            return await _userOutfitTemplateRepository.GetByUserIdAndTemplateIdAsync(userId, templateId);
        }

        public async Task<UserOutfitTemplate> CreateUserOutfitTemplateAsync(Guid userId, Guid templateId, string? notes = null)
        {
            var userOutfitTemplate = new UserOutfitTemplate
            {
                Id = Guid.NewGuid(),
                UserId = userId,
                TemplateId = templateId,
                Notes = notes,
                CreatedAt = DateTime.UtcNow,
                UpdatedAt = DateTime.UtcNow
            };

            await _userOutfitTemplateRepository.AddAsync(userOutfitTemplate);
            await _unitOfWork.SaveChangesAsync();

            return userOutfitTemplate;
        }

        public async Task<UserOutfitTemplate?> UpdateUserOutfitTemplateAsync(Guid id, string? notes)
        {
            var userOutfitTemplate = await _userOutfitTemplateRepository.GetByIdAsync(id);
            if (userOutfitTemplate == null)
                return null;

            if (notes != null) userOutfitTemplate.Notes = notes;

            userOutfitTemplate.UpdatedAt = DateTime.UtcNow;

            await _userOutfitTemplateRepository.UpdateAsync(userOutfitTemplate);
            await _unitOfWork.SaveChangesAsync();

            return userOutfitTemplate;
        }

        public async Task<bool> DeleteUserOutfitTemplateAsync(Guid id)
        {
            var userOutfitTemplate = await _userOutfitTemplateRepository.GetByIdAsync(id);
            if (userOutfitTemplate == null)
                return false;

            await _userOutfitTemplateRepository.DeleteAsync(userOutfitTemplate);
            await _unitOfWork.SaveChangesAsync();

            return true;
        }
    }

    /// <summary>
    /// 搭配建议服务实现
    /// </summary>
    public class OutfitSuggestionService : IOutfitSuggestionService
    {
        private readonly IOutfitSuggestionRepository _outfitSuggestionRepository;
        private readonly IOutfitRepository _outfitRepository;
        private readonly IClothingRepository _clothingRepository;
        private readonly IUnitOfWork _unitOfWork;

        public OutfitSuggestionService(
            IOutfitSuggestionRepository outfitSuggestionRepository,
            IOutfitRepository outfitRepository,
            IClothingRepository clothingRepository,
            IUnitOfWork unitOfWork)
        {
            _outfitSuggestionRepository = outfitSuggestionRepository;
            _outfitRepository = outfitRepository;
            _clothingRepository = clothingRepository;
            _unitOfWork = unitOfWork;
        }

        public async Task<OutfitSuggestion?> GetOutfitSuggestionByIdAsync(Guid id)
        {
            return await _outfitSuggestionRepository.GetByIdAsync(id);
        }

        public async Task<IEnumerable<OutfitSuggestion>> GetOutfitSuggestionsByUserIdAsync(Guid userId)
        {
            return await _outfitSuggestionRepository.GetByUserIdAsync(userId);
        }

        public async Task<IEnumerable<OutfitSuggestion>> GetOutfitSuggestionsByUserIdAndDateAsync(Guid userId, DateTime date)
        {
            return await _outfitSuggestionRepository.GetByUserIdAndDateAsync(userId, date);
        }

        public async Task<OutfitSuggestion> CreateOutfitSuggestionAsync(Guid userId, Guid outfitId, DateTime date, string reason)
        {
            var outfitSuggestion = new OutfitSuggestion
            {
                Id = Guid.NewGuid(),
                UserId = userId,
                OutfitId = outfitId,
                Date = date,
                Reason = reason,
                IsAccepted = false,
                CreatedAt = DateTime.UtcNow,
                UpdatedAt = DateTime.UtcNow
            };

            await _outfitSuggestionRepository.AddAsync(outfitSuggestion);
            await _unitOfWork.SaveChangesAsync();

            return outfitSuggestion;
        }

        public async Task<OutfitSuggestion?> UpdateOutfitSuggestionAsync(Guid id, string? reason, bool? isAccepted)
        {
            var outfitSuggestion = await _outfitSuggestionRepository.GetByIdAsync(id);
            if (outfitSuggestion == null)
                return null;

            if (reason != null) outfitSuggestion.Reason = reason;
            if (isAccepted.HasValue) outfitSuggestion.IsAccepted = isAccepted.Value;

            outfitSuggestion.UpdatedAt = DateTime.UtcNow;

            await _outfitSuggestionRepository.UpdateAsync(outfitSuggestion);
            await _unitOfWork.SaveChangesAsync();

            return outfitSuggestion;
        }

        public async Task<bool> DeleteOutfitSuggestionAsync(Guid id)
        {
            var outfitSuggestion = await _outfitSuggestionRepository.GetByIdAsync(id);
            if (outfitSuggestion == null)
                return false;

            await _outfitSuggestionRepository.DeleteAsync(outfitSuggestion);
            await _unitOfWork.SaveChangesAsync();

            return true;
        }

        public async Task<IEnumerable<OutfitSuggestion>> GenerateOutfitSuggestionsAsync(Guid userId, DateTime date, string occasion, string weather)
        {
            // 获取用户的所有服装
            var userClothings = await _clothingRepository.GetByUserIdAsync(userId);
            
            // 获取用户的所有搭配
            var userOutfits = await _outfitRepository.GetByUserIdAsync(userId);
            
            // 根据场景和季节筛选合适的搭配
            var suitableOutfits = userOutfits.Where(o => 
                o.Occasion == occasion && 
                o.Season == GetSeasonByDate(date))
                .ToList();
            
            // 如果没有找到合适的搭配，根据天气和场景生成新的搭配建议
            if (!suitableOutfits.Any())
            {
                // 这里可以添加更复杂的算法来生成搭配建议
                // 简化版：随机选择一个搭配作为建议
                var randomOutfit = userOutfits.OrderBy(o => Guid.NewGuid()).FirstOrDefault();
                if (randomOutfit != null)
                {
                    suitableOutfits.Add(randomOutfit);
                }
            }
            
            // 创建搭配建议
            var suggestions = new List<OutfitSuggestion>();
            foreach (var outfit in suitableOutfits.Take(3)) // 最多返回3个建议
            {
                var reason = $"根据{occasion}场景和{weather}天气，推荐此搭配";
                var suggestion = await CreateOutfitSuggestionAsync(userId, outfit.Id, date, reason);
                suggestions.Add(suggestion);
            }
            
            return suggestions;
        }
        
        private string GetSeasonByDate(DateTime date)
        {
            int month = date.Month;
            if (month >= 3 && month <= 5)
                return "春季";
            else if (month >= 6 && month <= 8)
                return "夏季";
            else if (month >= 9 && month <= 11)
                return "秋季";
            else
                return "冬季";
        }
    }
}